<template class="center">
    <el-container>
        <el-header>
            <Tops></Tops>
        </el-header>
        <el-main class="content">
           <span>修改密码</span>
           <div class="formCon">
               <el-form :model="ruleForm" status-icon :rules="rules" ref="ruleForm" label-width="100px" class="demo-ruleForm">
                <el-form-item label="原密码" prop="pass">
                    <el-input type="password" v-model="ruleForm.pass" autocomplete="off" style="width: 50%;"></el-input>
                </el-form-item>
                <el-form-item label="新认密码" prop="checkPass">
                    <el-input type="password" v-model="ruleForm.checkPass" autocomplete="off" style="width: 50%;"></el-input>
                </el-form-item>
                <el-form-item label="确认新密码" prop="sure">
                    <el-input type="password" v-model.number="ruleForm.sure" autocomplete="off" style="width: 50%;"></el-input>
                </el-form-item>
                <el-form-item>
                    <el-button type="primary" @click="submitForm('ruleForm')">提交</el-button>
                    <el-button @click="resetForm('ruleForm')">重置</el-button>
                </el-form-item>
                </el-form>
           </div>
        </el-main>
    </el-container>
</template>
<script>
import Tops from "../components/Top";
export default {
  data() {
      
      var validatePass = (rule, value, callback) => {
        if (value == '') {
          callback(new Error('请输入原密码'));
        } else {
          if (this.ruleForm.checkPass != '') {
            this.$refs.ruleForm.validateField('checkPass');
          }
          callback();
        }
      };
      var validatePass2 = (rule, value, callback) => {
        if (!value) {
          return callback(new Error('请输入新密码'));
        }
       
      };
        var checkSure = (rule, value, callback) => {
        if (value == '') {
          callback(new Error('请再次输入新密码'));
        } else if (value != this.ruleForm.checkPass) {
          callback(new Error('两次输入密码不一致!'));
        } else {
          callback();
        }
      };
    return {
        ruleForm: {
          pass: '',
          checkPass: '',
          sure: ''
        },
        rules: {
          pass: [
            { validator: validatePass, trigger: 'blur' }
          ],
          checkPass: [
            { validator: validatePass2, trigger: 'blur' }
          ],
          sure: [
            { validator: checkSure, trigger: 'blur' }
          ]
        }
    };
  },   
  computed:{
  },
  created () {
  },
  methods: {
      sureupdate(id) {
      this.$http
        .post("/UpdateProject", {
          projId: id,
          projName: this.updateMess.projName,
        })
        .then((result) => {
          this.data = result.data;
          if ((this, data.status == "200")) {
            next();
          }
        });
      location.reload();
    },
    submitForm(formName) {
    this.$refs[formName].validate((valid) => {
        if (valid) {
        console.log('submit!');
        } else {
        console.log('error submit!!');
        return false;
        }
    });
    },
    resetForm(formName) {
    this.$refs[formName].resetFields();
    }
  },
  components: {
    Tops,
  },
  mounted() { 
  },
};
</script>
<style lang="stylus" scoped>

.content{
    width:50%;
    margin: 1.5rem auto;
}
.content span{
    font-size :28px;
}
.formCon{
    margin-top:4rem;
}
</style>